package com.stud.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.stud.common.enums.WorkflowDefinitionEnum;
import com.stud.common.mybatis.BaseServiceImpl;
import com.stud.system.domain.WorkflowDefinitionTask;
import com.stud.system.mapper.WorkflowDefinitionTaskMapper;
import com.stud.system.service.WorkflowDefinitionTaskService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 流程定义任务Service业务层处理
 *
 * @author Stud
 * @date 2023-03-06
 */
@Service
public class WorkflowDefinitionTaskServiceImpl extends BaseServiceImpl<WorkflowDefinitionTaskMapper, WorkflowDefinitionTask> implements WorkflowDefinitionTaskService {

    @Override
    public List<WorkflowDefinitionTask> listByDefinitionEnum(WorkflowDefinitionEnum workflowDefinitionEnum) {
        return listByDefinitionCode(workflowDefinitionEnum.toString());
    }

    @Override
    public List<WorkflowDefinitionTask> listByDefinitionCode(String definitionCode) {
        LambdaQueryWrapper<WorkflowDefinitionTask> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WorkflowDefinitionTask::getDefinitionCode, definitionCode);
        queryWrapper.orderByAsc(WorkflowDefinitionTask::getSortNum);
        return list(queryWrapper);
    }
}
